home *** CD-ROM | disk | FTP | other *** search
/ Painter Bear's Language Bridge — Italian / Bridge_ponte_itialian.iso / pc / helpers / open.dxr / 00037_brad's score stuff.txt < prev    next >
Encoding:
Text File  |  2001-02-22  |  1.5 KB  |  49 lines

  1. -- this updates the high score field if the score field becomes greater,
  2. if the high score is always being displayed, you would want to call this
  3. everytime the score changes
  4. on Update_High_Score
  5.   set high = integer(field "highscore")
  6.   set curr = integer(field "scoreField")
  7.   if (curr > high) then
  8.     put curr into field "highscore"
  9.   end if
  10. end
  11.  
  12. -----------
  13.  -- save high score
  14. -- this saves the high score to a file called robobhs.hsc in the OS
  15. directory.  the OS directory is c:\windows\system on the PC and
  16. something similar on the MAC
  17. -- nothing is returned for OS dir in 3.1,  so there is no high score
  18. saving with the 3.1 version of the game.  this snippet of code should go
  19. in whatever handler is
  20. -- responsible for writing the high score to disk.
  21.  
  22.   set highFile = getosdirectory()&"robobhs.hsc"
  23.   set myFile = new(xtra "FileIO")
  24.   openFile (myFile, highFile, 2)
  25.   writeString(myFile, field "highscore")
  26.   closeFile(myFile)
  27.  
  28. ----------------
  29.   -- get high score stuff
  30. -- this is for reading the highscore file and putting the value into a
  31. field called highscore.  this would most likely be placed in startMovie
  32.  
  33.   set highFile = getosdirectory()&"robobhs.hsc"
  34.   set myFile = new(xtra "FileIO")
  35.   openFile (myFile, highFile, 0)
  36.   if (status(myFile) < 0) then
  37.     closeFile(myFile)
  38.     createFile(myFile, highFile)
  39.     openFile (myFile, highFile, 0)
  40.   end if
  41.   set myString = readLine(myFile)
  42.   if (getLength(myFile) = 0) then
  43.     writeString myFile, "0"
  44.     put "0" into field "highscore"
  45.   else
  46.     put myString into field "highscore"
  47.   end if
  48.   closeFile(myFile)
  49.